﻿using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TXTD.Admin.Data.Entitys.System;
using TXTD.Admin.Framework.ExpressionCore;
using TXTD.Admin.Interface.System;
using TXTD.Admin.Model.Paging;

namespace TXTD.Admin.Service.System
{
    public class SysDictionaryItemsService : BaseService<SysDictionaryItems>, ISysDictionaryItemsService
    {
        public SysDictionaryItemsService(DbContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
        {
        }

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <returns></returns>
        public PageResult<SysDictionaryItems> GetPageList(SysDictionaryItems model)
        {
            #region 动态凭借查询条件
            ExpressionHelper<SysDictionaryItems> expressionHelper = new ExpressionHelper<SysDictionaryItems>();
            if (string.IsNullOrEmpty(model.DictionaryId))
                model.DictionaryId = "-";
            expressionHelper.Eq(nameof(SysDictionaryItems.DictionaryId), model.DictionaryId);
            expressionHelper.Contains(nameof(SysDictionaryItems.ItemKeyCode), model.ItemKeyCode);
            var where = expressionHelper.GetExpression();
            #endregion
            return QueryPageList<SysDictionaryItems>(where);
        }
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public int Add(SysDictionaryItems model)
        {
            return InsertModel(model);
        }
        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public int Update(SysDictionaryItems model)
        {
            return UpdateModel(model, model.DictionaryItemId);
        }
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>

        public int DeleteById(string id)
        {
            return RemoveById(id);
        }
    }
}